<?php


namespace app\middleware;


use app\dao\shop\ShopDao;

class Merchant
{
    public function handle($request, \Closure $next)
    {
        $shopDao = new ShopDao();

        $shop = $shopDao->getShopAndWxCodeByName(SUBDOMAIN);

        //验证商户是否存在
        if ($shop == null || $shop->is_ban == 1)
        {
            abort(502);
        }

        bind('merchant', $shop);

        return $next($request);
    }
}